from flask import Blueprint, redirect

# 创建蓝图对象
admin_bp = Blueprint("admin", __name__, url_prefix="/admin")

from info.modules.admin.views import *

# 使用请求钩子函数， 在每次请求之前对用户权限进行判断
@admin_bp.before_request
def is_admin_user():
    """判断是否管理员用户"""

    print(request.url)
    if request.url.endswith("/admin/login"):
        pass
    else:
        user_id = session.get("user_id")
        is_admin = session.get("is_admin", False)

        if not user_id or not is_admin:
            return redirect("/")

